import { http } from "@/utils/http";
import type { TableItem } from "../type";
type ResultTable = {
  total?: number;
  data?: Array<any>;
};

//查询核算报告
export const accountingReportquery = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/query`, {
    data
  });
};

//填报详情
export const accountingReportdetail = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/detail`, {
    data
  });
};

//编辑填报
export const accountingReportedit = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/edit`, {
    data
  });
};

//新增核算报告
export const accountingReportsave = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/save`, {
    data
  });
};

//删除核算报告
export const accountingReportdelete = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/delete`, {
    data
  });
};

//计算碳排放量
export const accountingReportaccount = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/account`, {
    data
  });
};

//核算结果
export const accountingReportaccountingResult = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/accountingResult`, {
    data
  });
};

//核算后保存
export const accountingReportsaveAfterAccounting = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/saveAfterAccounting`, {
    data
  });
};

// 核算模板下拉框
export const accountingReporttemplateList = (params: object | undefined) =>
  http.request(
    "get",
    `/energy/accountingReport/templateList`,
    { params },
    {
      headers: { noLoading: false }
    }
  );

// 活动水平来源下拉框
export const accountingReportactivityLevelSource = (params: object | undefined) =>
  http.request(
    "get",
    `/energy/accountingReport/activityLevelSource`,
    { params },
    {
      headers: { noLoading: false }
    }
  );

//删除碳排放报告
export const emissionReportdelete = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/emissionReport/delete`, {
    data
  });
};

//校验模板
export const accountingReportvalidateTemplate = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/validateTemplate`, {
    data
  });
};

//碳排放报告预览
export const emissionReportpreview = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/emissionReport/preview`, {
    data
  });
};

export const accountingReportimportAccounting = (data?: object | undefined, cb?: (err: any) => any) =>
  http.request<Array<TableItem>>(
    "post",
    `/energy/accountingReport/importAccounting`,
    { data },
    { headers: { noLoading: true, "Content-Type": "multipart/form-data" } },
    cb
  );

//核算导出
export const accountingReportexport = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/export`, {
    data
  });
};
//计算碳排放量环比百分比
export const accountingReportaccountMomPercent = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/accountMomPercent`, {
    data
  });
};

//设施活动排放趋势柱状图
export const accountingReportqueryFacilityDailyEmission = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/queryFacilityDailyEmission`, {
    data
  });
};

//活动水平数据同步
export const accountingReportsyncActivityLevelValue = (data?: object) => {
  return http.request<ResultTable>("post", `/energy/accountingReport/syncActivityLevelValue`, {
    data
  });
};
//过滤出有关联能源指标的设施活动
export const accountingReportFilterFacility = (data: object) => {
  return http.request("post", `/energy/accountingReport/filterFacility`, {
    data
  });
};
